<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 400px;
            height: 400px;
            background-color: #000;
            margin: 50px;
            /* position: relative; */
        }

        .a {
            width: 100px;
            height: 100px;
            background-color: #f00;
            margin: auto;
            border: 10px solid #ff0;
        }
    </style>
</head>

<body>

    <div class="box">
        <div class="a"></div>
    </div>

    <script>

        // offsetLeft / offsetTop   元素距离最近的具有定位的祖先元素的位置

        // offsetParent  元素距离最近的具有定位的祖先元素

        // clientLeft / clientTop   元素的内容距离元素的边缘的距离 --- 边框的宽度
        //     clientLeft 盒子左边框的宽度
        //     clientTop  盒子上边框的宽度

        var oA = document.querySelector('.a');

        console.log(oA.offsetLeft);

        console.log(oA.offsetParent);

        console.log(oA.clientLeft);

    </script>

</body>

</html>